//
// option_4.cpp for 202loi in /home/morel_t//Rendu/maths/202loi
// 
// Made by thomas morel
// Login   <morel_t@epitech.net>
// 
// Started on  Fri Mar  9 17:15:48 2012 thomas morel
// Last update Fri Mar  9 17:52:44 2012 florian jousseau
//

#include "202loi.h"

static void	header(std::string **tab)
{
  for (int x = 1; x <= 9; x++)
    tab[0][x] += toStringHeader(x+1);
  tab[0][0] = "z";
  tab[1][0] = "F(z)";
}

static int	Ex[] = {1, 2, 3, 4, 5};
static int	Ey[] = {1, 2, 3, 4, 5};

static double	nbTime(int val)
{
  double	value = 0;

  for (int i = 0; i < 5; i++)
    {
      for (int j = 0; j < 5; j++)
	{
	  if ((Ex[i] + Ey[j]) == val)
	    value++;
	}
      ;
    }
  return (value);
}

static double	nbTimeMax()
{
  double	value = 0;

  for (int i = 0; i < 5; i++)
    {
      for (int j = 0; j < 5; j++)
	value++;
      ;
    }
  return (value);
}

void		option_4(t_tab *tab)
{
  double	tmp = 0;

  tab->tab4 = new Table(11, 2);
  header(tab->tab4->getSTab());
  for (int x = 1; x <= 9; x++)
    {
      tmp = (nbTime(x+1) / nbTimeMax());
      tab->tab4->getSTab()[1][x] = toString(tmp);
    }
  for (int x = 2; x <= 9; x++)
    tab->tab4->getSTab()[1][x] = toString(toDouble(tab->tab4->getSTab()[1][x]) +
					  toDouble(tab->tab4->getSTab()[1][x-1]));
  //tab->tab4->printTab();
}
